<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>

</style>

<body>
    <div id="app">
        <book>
            <template #default>
                <img src="./imgs/logo.png">
            </template>
            <template #footer>
                <p>我是footer里的p</p>
            </template>
        </book>
    </div>
</body>

</html>
<script src="./js/vue.global.js"></script>
<script>
    const { createApp, h } = Vue;

    // let vNode = h("div",{id:"box01",innerHTML:"我是盒子01"});//创建一个div标签的虚拟dom。

    const comments = {
        render(){
            return h("ul",[h("li","书不错"),h("li","女朋友也觉得书不错")])
        }
    }

    let book = {
        render() {
            // return h("div",{id:"box01",innerHTML:"我是盒子01"})
            // return h("div",{id:"box01",class:"cls"},"我是盒子01")
            // return h(
            //     "div",
            //     {id:"box01",class:"cls"},
            //     [
            //         h("div",{id:"box01_01"},"我是第一个子元素div"),
            //         h(
            //             "p",
            //             {id:"box01_02"},
            //             [
            //                 h("span",{class:"span_cls01"},"我是第一个span"),
            //                 h("span",{class:"span_cls02"},"我是第二个span"),
            //             ]
            //         )
            //     ]
            // )

            return [
                h(
                    "div",
                    { id: "box01", class: "cls" },
                    [
                        h("div", { id: "box01_01" }, "我是第一个子元素div"),
                        h(
                            "p",
                            { id: "box01_02" },
                            [
                                h("span", { class: "span_cls01" }, "我是第一个span"),
                                h("span", { class: "span_cls02" }, "我是第二个span"),
                            ]
                        )
                    ]
                ),
                h("ul"),
                h(
                    "div",
                    { "id": "box03" },
                    [
                        h("div", { id: "box03_01" }),
                        this.$slots.default()  //<slot></slot>                      
                    ]
                ),                
                h(
                    "div",
                    { "id": "box04" },
                    [
                        h("div", { id: "box04_01" }),
                        this.$slots.footer()  //<slot name="footer"></slot>                      
                    ]
                ),
                h(
                    comments,
                    {
                        class:"coments_cls"
                    }
                )
            ]
        }
    }



    // 1、创建一个应用
    let app = createApp({
        data() {
            return {
                msg: "hi"
            }
        },
        components: {
            book
        }
    });



    // 2、把应用进行渲染（和模板进行关联）
    app.mount("#app");


</script>